{% extends "ejeje/layout.html" %}

{% block head %}
{{ block.super }}

      <script type="text/javascript" src="/media/jquery.dataTables.min.js"></script>
		  <style type="text/css" title="currentStyle">
			  @import "/media/css/demo_page.css";
			  @import "/media/css/demo_table.css";
		  </style>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function() {
        $('#searchtable').dataTable({
                "bServerSide": true, 
                "sAjaxSource": "/finn.json",
              	"aoColumns": [ 
			            /* uri */   { "fnRender": function ( oObj ) {
				              if(oObj.aData[0] == "null") {
				                  return '<button class="order">Bestill</button>';
				              } else {
				                  return '<a href="'+oObj.aData[0]+'">Les</a>';
				              }
			            } },
			            /* offentlig */  { "bVisible": false },
			            /* tittel */  { "fnRender": function (oObj) {
			                var cl = "";
			                if(oObj.aData[1] == "false") { // ikke offentlig
			                    cl += 'uoffentlig';
			                }
			                cl += ' retning-'+oObj.aData[5];
			                return '<span class="'+cl+'">'+oObj.aData[2]+'</span>';
			            } },
			            /* dokumentdato */  { "fnRender": function (oObj) {
			                var dat = "";
			                if(oObj.aData[3] != "null") { // kjent dok.dato
			                    dat = oObj.aData[3];
			                } else if(oObj.aData[4] != "null") { // kjent arkivdato
			                    dat = oObj.aData[4];
			                } else {
			                    dat = "n/a";
			                }
			                return dat;
			            } },
			            /* arkivdato */  { "bVisible": false },
			            /* retning */  { "bVisible": false },
			            /* organisasjon */  null,
			            /* sakskompleks */  { "bVisible": false }
			            ]
        });
} );
/* ]]> */
</script>

{% endblock %}

{% comment %}
                "{{row.uri}}",
                "{{row.offentlig|yesno:"true,false"}}"
                "{{row.tittel|title}}",
                "{{row.dokumentdato|default:"null"}}",
                "{{row.arkivdato|default:"null"}}",
                "{{row.retning}}",
                "{{row.organisasjon}}",
                "{{row.sakskompleks}}",
=>

            <th>bestill</th>
            <th>tittel</th>
            <th>dato</th>
            <th>organisasjon</th>

{% endcomment %}


{% block body %}
<div style="width:50%;">
  {% include "ejeje/searchtable.html" %}
</div>
{% endblock %}
